﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ingresaDatosProceso.aspx.cs"
    Inherits="WebContratos.ingresaDatosProceso" %>

<%@ Register Assembly="DevExpress.Web.ASPxEditors.v10.2, Version=10.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register TagPrefix="cc1" Namespace="BunnyBear" Assembly="msgBox" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Página sin título</title>


    <script type="text/javascript">
    // <![CDATA[
        function phone_InitAndKeyUp(s,e) {
            //document.getElementById("phoneValue").innerHTML=s.GetValue();
        }
        function price_InitAndKeyUp(s,e) {
            document.getElementById("lblMontoSinMas").innerHTML=s.GetValue();
           
        }
    // ]]>
    </script>

    <link rel="stylesheet" type="text/css" media="all" href="css/calendario/themeBlue.css"
        title="Aqua" />
    <link rel="alternate stylesheet" type="text/css" media="all" href="css/calendario/theme(1)Blue.css"
        title="Tiger" />

    <script type="text/javascript" src="js/calendario/calendar.js"></script>

    <script type="text/javascript" src="js/calendario/calendar-en.js"></script>

    <script type="text/javascript" src="js/deluxe/dpopupwindow.js"></script>

    <script type="text/javascript" src="js/deluxe/deluxe-popup-window.js"></script>

    <script type="text/javascript" src="js/FormatValor.js"> </script>

    <script type="text/javascript">
		
		var oldLink = null;
		
		function setActiveStyleSheet(link, title) 
		{
		  var i, a, main;
		  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
			if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
			  a.disabled = true;
			  if(a.getAttribute("title") == title) a.disabled = false;
			}
		  }
		  if (oldLink) oldLink.style.fontWeight = 'normal';
		  oldLink = link;
		  link.style.fontWeight = 'bold';
		  return false;
	    }

		function selected(cal, date) {
			  cal.sel.value = date; // just update the date in the input field.
			  if (cal.dateClicked && (cal.sel.id == "sel1" || cal.sel.id == "sel3"))
				// if we add this call we close the calendar on single-click.
				// just to exemplify both cases, we are using this only for the 1st
				// and the 3rd field, while 2nd and 4th will still require double-click.
				cal.callCloseHandler();
		}

		function closeHandler(cal) {
			  cal.hide();                        // hide the calendar
			//  cal.destroy();
			  _dynarch_popupCalendar = null;
		}
            
        
        function showCalendarControl(id, idImage, format, showsTime, showsOtherMonths) 
        {
			  var el = dg.GetEditFormElement('dg1',id);
			  var idIma = dg.GetEditFormElement('dg1',idImage);

			  if (_dynarch_popupCalendar != null) {
				// we already have some calendar created
				_dynarch_popupCalendar.hide();                 // so we hide it first.
			  } else {
				// first-time call, create the calendar.
				var cal = new Calendar(1, null, selected, closeHandler);
				// uncomment the following line to hide the week numbers
				// cal.weekNumbers = false;
				if (typeof showsTime == "string") {
				  cal.showsTime = true;
				  cal.time24 = (showsTime == "24");
				}
				if (showsOtherMonths) {
				  cal.showsOtherMonths = true;
				}
				_dynarch_popupCalendar = cal;                  // remember it in the global var
				cal.setRange(1900, 2070);        // min/max year allowed.
				cal.create();
			  }
			  _dynarch_popupCalendar.setDateFormat(format);    // set the specified date format
			  
			 // alert(el);
			  
			  _dynarch_popupCalendar.parseDate(el.value);      // try to parse the text in field
			  _dynarch_popupCalendar.sel = el;                 // inform it what input field we use

			  // the reference element that we pass to showAtElement is the button that
			  // triggers the calendar.  In this example we align the calendar bottom-right
			  // to the button.
			  _dynarch_popupCalendar.showAtElement(idIma, "Br");//(el.nextSibling, "Br");        // show the calendar

			  return false;
		}
            
			function showCalendar(id, idImage, format, showsTime, showsOtherMonths) {
			  var el = document.getElementById(id);
			  var idIma = document.getElementById(idImage);

			  if (_dynarch_popupCalendar != null) {
				// we already have some calendar created
				_dynarch_popupCalendar.hide();                 // so we hide it first.
			  } else {
				// first-time call, create the calendar.
				var cal = new Calendar(1, null, selected, closeHandler);
				// uncomment the following line to hide the week numbers
				// cal.weekNumbers = false;
				if (typeof showsTime == "string") {
				  cal.showsTime = true;
				  cal.time24 = (showsTime == "24");
				}
				if (showsOtherMonths) {
				  cal.showsOtherMonths = true;
				}
				_dynarch_popupCalendar = cal;                  // remember it in the global var
				cal.setRange(1900, 2070);        // min/max year allowed.
				cal.create();
			  }
			  _dynarch_popupCalendar.setDateFormat(format);    // set the specified date format
			  
			 // alert(el);
			  
			  _dynarch_popupCalendar.parseDate(el.value);      // try to parse the text in field
			  _dynarch_popupCalendar.sel = el;                 // inform it what input field we use

			  // the reference element that we pass to showAtElement is the button that
			  // triggers the calendar.  In this example we align the calendar bottom-right
			  // to the button.
			  _dynarch_popupCalendar.showAtElement(idIma, "Br");//(el.nextSibling, "Br");        // show the calendar

			  return false;
			}

			var MINUTE = 60 * 1000;
			var HOUR = 60 * MINUTE;
			var DAY = 24 * HOUR;
			var WEEK = 7 * DAY;

			// If this handler returns true then the "date" given as
			// parameter will be disabled.  In this example we enable
			// only days within a range of 10 days from the current
			// date.
			// You can use the functions date.getFullYear() -- returns the year
			// as 4 digit number, date.getMonth() -- returns the month as 0..11,
			// and date.getDate() -- returns the date of the month as 1..31, to
			// make heavy calculations here.  However, beware that this function
			// should be very fast, as it is called for each day in a month when
			// the calendar is (re)constructed.
			function isDisabled(date) {
			  var today = new Date();
			  return (Math.abs(date.getTime() - today.getTime()) / DAY) > 10;
			}

			function flatSelected(cal, date) {
			  var el = document.getElementById("preview");
			  el.innerHTML = date;
			}

			function showFlatCalendar() {
			  var parent = document.getElementById("display");

			  // construct a calendar giving only the "selected" handler.
			  var cal = new Calendar(0, null, flatSelected);



			  // hide week numbers
			  cal.weekNumbers = false;

			  // We want some dates to be disabled; see function isDisabled above
			  cal.setDisabledHandler(isDisabled);
			  cal.setDateFormat("%A, %B %e");

			  // this call must be the last as it might use data initialized above; if
			  // we specify a parent, as opposite to the "showCalendar" function above,
			  // then we create a flat calendar -- not popup.  Hidden, though, but...
			  cal.create(parent);

			  // ... we can show it here.
			  cal.show();
			}
	
	
		var hdTipoConsultaJa = '';
		var datoCodContra = '0';
		
		function abrirPopup(c_campo1, c_campo2, valor)
		{
            
           
		  campo1 = document.getElementById(c_campo1).value;
		  campo2 = document.getElementById(c_campo2).value;
		 
		  nomCampo1 = c_campo1;		  
		  nomCampo2 = c_campo2;
		  
		  var longiBusc = 0;
		  var longiBusc1 = 0;
		  
		  hdTipoConsultaJa = '';
		  
		  if(valor==1)
		  {
		    var dato = document.getElementById(c_campo1).value;  
		    longiBusc = dato.length;

		    var dato1 = document.getElementById(c_campo2).value;  
		    longiBusc1 = dato1.length;

		    
		    if (longiBusc < 3)
		      if(longiBusc1<4)
		      {
		        alert('Ingrese 3 Digitos de la Cedula del Contratista o el Nombre del Contratista');
		        return false;
		      }
		        
		    obtieneListaValores(campo1, campo2, 'consultaContratista');
			
		  }else if(valor==3)
		  {
		    obtieneListaValores(campo1, campo2, 'consultaFiscalizador');
		    
		  }else if(valor==2)
		  {
		    obtieneListaValores(campo1, campo2, 'consultaAdministrador');
		    
		  }else if(valor==4)
		  {
		  obtieneListaValores(campo1, campo2, 'consultaGerencia');
			
		  }else if(valor==5)
		  {
		     hdTipoConsultaJa = document.getElementById('hdTipoConsulta').value;
		     
		     if(hdTipoConsultaJa==1)
		         datoCodContra = '1';  
		     else
		         datoCodContra = '2';  
		         
		     obtieneListaValores(campo1, campo2, 'consultaCodProceso');
		  }
		}
        
        var obj;
              function getXMLHTTPRequest() 
              {
                 var xRequest=null;
                if (window.XMLHttpRequest) {
                xRequest=new XMLHttpRequest();
                }else if (typeof ActiveXObject != "undefined"){
                  xRequest=new ActiveXObject("Microsoft.XMLHTTP");
                }
                  return xRequest;
                }
            function obtieneListaValores(campo1, campo2, campo3)
            {
                obj=getXMLHTTPRequest();
                if(obj!=null)
                {
                    obj.onreadystatechange = ProcessResponse;
                    obj.open("GET", "Srvlets/ProcessedPage.aspx?campo1="+campo1+"&campo2="+campo2+"&campo3="+campo3+"&campo4="+hdTipoConsultaJa,  true);
                    obj.send(null);         
                }
                return false;
            }

            function ProcessResponse()
            {
                var basePath = "";
                
                if(obj.readyState == 4)
                {
                    if(obj.status == 200)
                    {
                        var retval=obj.responseText;  
                        
                        window.open(basePath+'General/encontrarDatos.aspx?exP='+navigator.appName.indexOf("Microsoft")+'&nomCampo1='+nomCampo1+'&nomCampo2='+nomCampo2+'&conServ='+datoCodContra,'Consulta','width=590px,height=300px');

                    }
                    else
                    {
                        alert("Error retrieving data!" );
                    }   
                }
            }

    </script>

    <style type="text/css">
        .style1
        {
            height: 23px;
        }
        .cajaTexto
        {
            font-size: 11px;
            font: Tahoma;
            border-left: #6699CC 1px solid;
            border-bottom: #4167B0 1px solid;
            border-right: #6699CC 1px solid;
            border-top: #4167B0 1px solid;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="lblMontoSinMas" runat="server" Text=""></asp:Label>
        <table style="width: 100%" cellspacing="0" cols="0" cellpadding="0">
            <tr>
                <td align="left" valign="bottom" style="width: 80%">
                    <span style="height: 35px; font-weight: bold; font-size: 18px; color: #3A5389; font-family: Tahoma;">
                        Ingreso de Codigos de Procesos</span>
                </td>
            </tr>
        </table>
        <table bgcolor="#EAF3FF" style="width: 100%; height: 100%; font-size: 11px; font-family: Tahoma;
            border-right: #b0c2d0 1px solid; border-top: #b0c2d0 1px solid; border-left: #b0c2d0 1px solid;
            border-bottom: #b0c2d0 1px solid">
            <tr>
                <td class="style1">
                    <asp:Label ID="lblCodigoProceso" runat="server" Text="Codigo de Proceso:"></asp:Label>
                </td>
                <td class="style1">
                    <dx:ASPxTextBox ID="txtCodProceso" runat="server" Width="150px">
                        <ValidationSettings CausesValidation="True">
                            <RequiredField ErrorText="Ingrese el Codigo de Proceso" IsRequired="True" />
                        </ValidationSettings>
                    </dx:ASPxTextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Tipo de Contrato:
                </td>
                <td>
                    <asp:DropDownList runat="server" DataTextField="CATALOGO_DESCRIPCION" DataValueField="CATALOGO_CODIGO"
                        DataSourceID="SqlDataSource4" CssClass="cajaTexto" Width="170px"
                        ID="LstTipoContrato">
                    </asp:DropDownList>
                    <asp:SqlDataSource runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString3 %>"
                        ProviderName="<%$ ConnectionStrings:ConnectionString3.ProviderName %>" SelectCommand="select catalogo_codigo, catalogo_descripcion from web_catalogo where catalogo_nombre = 'TIPCONTR'
order by 2" ID="SqlDataSource4"></asp:SqlDataSource>
                </td>
            </tr>
            <tr>
                <td>
                    Contratista:
                </td>
                <td>
                    <table cellpadding="0" cellspacing="0">
                        <tr>
                            <td>
                                <asp:TextBox ID="txtContra" CssClass="cajaTexto" Width="100px" MaxLength="14" runat="server"></asp:TextBox>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                            <td>
                                <asp:TextBox ID="txtDescContra" CssClass="cajaTexto" Width="250px" MaxLength="250"
                                    runat="server"></asp:TextBox>
                            </td>
                            <td>
                                <asp:ImageButton runat="server" CausesValidation="False" OnClientClick="abrirPopup('txtContra','txtDescContra',1);return false;"
                                    Height="16px" Width="16px" ID="ImageButton4" ImageUrl="images/ico_18_126.gif">
                                </asp:ImageButton>
                            </td>
                        </tr>
                    </table>
                </td>
                </td>
            </tr>
            <tr>
                <td>
                    Representante Contratista:
                </td>
                <td>
                    <asp:TextBox ID="txtRepreContra" runat="server" CssClass="cajaTexto" MaxLength="250"
                        Width="370px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Gerencia Solicitante:
                </td>
                <td>
                    <table cellpadding="0" cellspacing="0">
                        <tr>
                            <td>
                                <asp:TextBox ID="txtGerencia" runat="server" CssClass="cajaTexto" MaxLength="14"
                                    Width="100px"></asp:TextBox>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                            <td>
                                <asp:TextBox ID="txtDesGerencia" runat="server" CssClass="cajaTexto" MaxLength="40"
                                    Width="250px"></asp:TextBox>
                            </td>
                            <td>
                                <asp:ImageButton ID="ImageButton5" runat="server" CausesValidation="False" Height="16px"
                                    ImageUrl="images/ico_18_126.gif" OnClientClick="abrirPopup('txtGerencia','txtDesGerencia',4);return false;"
                                    Width="16px" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    Certificacion Presupuestaria:
                </td>
                <td>
                    <asp:TextBox ID="txtCerpresu" runat="server" CssClass="cajaTexto" MaxLength="100"
                        Width="200px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lblMonto" runat="server" Text="Monto del Contrato:"></asp:Label>
                </td>
                <td>
                <table cellpadding=0 cellspacing=0>
                  <tr>
                   <td>
                    <dx:ASPxTextBox ID="txtMonto" runat="server" Width="155px">
                        <ValidationSettings CausesValidation="True">
                            <RequiredField ErrorText="Ingrese el Monto" IsRequired="True" />
                        </ValidationSettings>
                        <MaskSettings Mask="$<0..999999999g>.<00..99>" IncludeLiterals="DecimalSymbol" />
                        <ValidationSettings ErrorDisplayMode="ImageWithTooltip" />
                        <ClientSideEvents Init="price_InitAndKeyUp" KeyUp="price_InitAndKeyUp" />
                    </dx:ASPxTextBox>
                   </td>
                   <td>
                    (Sin IVA)
                   </td> 
                   </tr>
                 </table>
                </td>
            </tr>
            <tr>
                <td valign="top">
                    <asp:Label ID="lblObjetoContrato" runat="server" Text="Objeto del Contrato:"></asp:Label>
                </td>
                <td>
                    <dx:ASPxMemo ID="ASPxMemo1" runat="server" NullText="" Width="226px" Height="81px">
                        <ValidationSettings>
                            <RequiredField ErrorText="Ingrese el Objeto del Proceso" IsRequired="True" />
                        </ValidationSettings>
                    </dx:ASPxMemo>
                </td>
            </tr>
            <tr>
                <td>
                    Fecha de Publicacion
                </td>
                <td>
                  <table cellpadding=0 cellspacing=0 >
                    <tr>
                    <td>
                    <dx:ASPxTextBox ID="txtFechaPubli" runat="server" Width="155px">
                        <ValidationSettings>
                            <RequiredField IsRequired="True" />
                        </ValidationSettings>
                    </dx:ASPxTextBox>
                    </td>
                    <td>
                    <img style="cursor: pointer;" id="txtFechaSuscripcion02" border="0" alt="Calendario"
                        width="16px" height="16px" src="images/calendar.png" onclick="return showCalendar(&#39;txtFechaPubli_I&#39;,&#39;txtFechaSuscripcion02&#39;, &#39;%Y-%m-%d&#39;, &#39;24&#39;, true);"><span
                            class="style6">YYYY-MM-DD</span>
                    </td>
                   </tr>
                  </table>
                </td>
            </tr>
            <tr>
                <td>
                    Url
                </td>
                <td>
                    <dx:ASPxTextBox ID="ASPxTextUrl" runat="server" Height="17px" Width="414px">
                    </dx:ASPxTextBox>
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;
                </td>
                <td>
                    <table>
                        <tr>
                            <td>
                                <dx:ASPxButton ID="ASPxBtnGrabar" runat="server" Text="Grabar" OnClick="ASPxBtnGrabar_Click">
                                </dx:ASPxButton>
                            </td>
                            <td>
                                <dx:ASPxButton ID="ASPxBtnCancelar" runat="server" Text="Cancelar" AutoPostBack="False"
                                    CausesValidation="False">
                                </dx:ASPxButton>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
    <cc1:msgBox ID="MsgBox1" Style="z-index: 103; left: 536px; position: absolute; top: 184px"
        runat="server"></cc1:msgBox>
    </form>
</body>
</html>
